<div class="box-background-content">
    <div class="bg-sitebar">
        <div class="row-fluid fix-tieude-home">
            <div class="span6 fix-vmn-top">
                <img src="<?php echo DOMAIN;?>images/vmn-top.png"/>
                <?php echo lang('sanphamthietkemoi');?>
            </div>
            <div class="span6"><?php echo lang('sanphamthietkenoibat');?></div>
        </div>
    </div>
    <div class="row-fluid">
        <div class="noidung-one">
        <?php
            $this->Catproduct = ClassRegistry::init('Catproduct');
            if(!empty($listtinmoi)){
            foreach($listtinmoi as $val){
        ?>
            <div class="box-content-thiet-ke" id="<?php echo 'pajinate_one'.$val['id'];?>" parent_id="<?php echo $val['id'];?>">
                <img class="anh1" src="<?php echo DOMAIN;?>images/mt1t.png"/>
                <i class="fa fa-circle ileft" style="color: <?php if(!empty($val['mau'])) echo $val['mau']; else echo '#fc6e51;';?>"></i>
                <div class="box-bar-title">
                    <div class="row-fluid">
                        <div class="span5">
                            <div class="bg-nut-sp" style="background: <?php if(!empty($val['mau'])) echo $val['mau']; else echo '#fc6e51;';?> url('<?php echo DOMAIN;?>images/icon-btn-home.png') repeat-x bottom">
                                <img class="iconYtuong" src="<?php echo DOMAIN;?>img/h18/<?php echo $val['images'];?>"/>
                                <?php echo $val['name'];?>
                            </div>
                        </div>
                        <div class="span7 text-right chon-nghe">
                            <?php echo lang('nghanhnghe');?>
                            <select name="nghanhnghe" class="nganhnghe">
                                <option value=""><?php echo lang('tatca');?></option>
                                <?php
                                    $listdanhmuc = $this->Catproduct->find('all', array(
                                        'fields' => array('id', 'name', 'name_eng', 'parent_id'),
                                        'conditions' => array(
                                            'Catproduct.parent_id' => $val['id'],
                                            'Catproduct.status' => 1
                                        )
                                    ));
                                    foreach($listdanhmuc as $va){
                                ?>
                                    <option value="<?php echo $va['Catproduct']['id'];?>"> -- <?php echo $va['Catproduct']['name'];?></option>
                                    <?php
                                        $listdanhmuc12 = $this->Catproduct->find('all', array(
                                            'fields' => array('id', 'name', 'name_eng', 'parent_id'),
                                            'conditions' => array(
                                                'Catproduct.parent_id' => $va['Catproduct']['id'],
                                                'Catproduct.status' => 1
                                            )
                                        ));
                                        foreach($listdanhmuc12 as $valu){
                                    ?>
                                        <option value="<?php echo $valu['Catproduct']['id'];?>"> -- -- <?php echo $valu['Catproduct']['name'];?></option>
                                    <?php }?>
                                <?php }?>
                            </select>
                        </div>
                    </div>
                </div><!--end box-bar-title-->
                <div class="box-content-new home_content_one">

                </div><!--end box-content-new-->
            </div><!--end box-content-thiet-ke-->
            <div class="clear-content"></div><div class="clear-content"></div><div class="clear-content"></div>
        <?php }}?>
        </div><!--end noidung-one-->
        <div class="noidung-two">
        <?php
            if(!empty($listtinnoibat)){
            foreach($listtinnoibat as $val){
        ?>
            <div class="box-content-thiet-ke" id="<?php echo 'pajinate_two'.$val['id'];?>" parent_id="<?php echo $val['id'];?>">
                <img class="anh2" src="<?php echo DOMAIN;?>images/mt2t.png"/>
                <i class="fa fa-circle iright" style="color: <?php if(!empty($val['mau'])) echo $val['mau']; else echo '#fc6e51;';?>"></i>
                <div class="box-bar-title">
                    <div class="row-fluid">
                        <div class="span5">
                            <div class="bg-nut-sp" style="background: <?php if(!empty($val['mau'])) echo $val['mau']; else echo '#fc6e51;';?> url('<?php echo DOMAIN;?>images/icon-btn-home.png') repeat-x bottom">
                                <img class="iconYtuong" src="<?php echo DOMAIN;?>img/h18/<?php echo $val['images'];?>"/>
                                <?php echo $val['name'];?>
                            </div>
                        </div>
                        <div class="span7 text-right chon-nghe">
                            <?php echo lang('nghanhnghe');?>
                            <select name="nghanhnghe" class="nganhnghe">
                                <option value=""><?php echo lang('tatca');?></option>
                                <?php
                                    $listdanhmuc = $this->Catproduct->find('all', array(
                                        'fields' => array('id', 'name', 'name_eng', 'parent_id'),
                                        'conditions' => array(
                                            'Catproduct.parent_id' => $val['id'],
                                            'Catproduct.status' => 1
                                        )
                                    ));
                                    foreach($listdanhmuc as $va){
                                ?>
                                    <option value="<?php echo $va['Catproduct']['id'];?>"> -- <?php echo $va['Catproduct']['name'];?></option>
                                    <?php
                                        $listdanhmuc12 = $this->Catproduct->find('all', array(
                                            'fields' => array('id', 'name', 'name_eng', 'parent_id'),
                                            'conditions' => array(
                                                'Catproduct.parent_id' => $va['Catproduct']['id'],
                                                'Catproduct.status' => 1
                                            )
                                        ));
                                        foreach($listdanhmuc12 as $valu){
                                    ?>
                                        <option value="<?php echo $valu['Catproduct']['id'];?>"> -- -- <?php echo $valu['Catproduct']['name'];?></option>
                                    <?php }?>
                                <?php }?>
                            </select>
                        </div>
                    </div>
                </div><!--end box-bar-title-->
                <div class="box-content-new home_content_two">

                </div><!--end box-content-new-->
            </div><!--end box-content-thiet-ke-->
            <div class="clear-content"></div><div class="clear-content"></div><div class="clear-content"></div>
            <script>
$(document).ready(function(){
    $('#<?php echo 'pajinate_two'.$val['id'];?>').pajinate({
    	items_per_page : 1,
    });
});
</script>
        <?php }}?>
        </div><!--end noidung-two-->
    </div>
</div><!--end box-background-content-->


<script>
$(document).ready(function(){
    $(".home_content_one").each(function(){
        var e = $(this);
        $.post( "<?php echo DOMAIN;?>home/ajax/1/" + e.parent().attr('parent_id'), function( data ) {
          e.html( data );
        });
    });
    $(".home_content_two").each(function(){
        var e = $(this);
        $.post( "<?php echo DOMAIN;?>home/ajax/2/" + e.parent().attr('parent_id'), function( data ) {
          e.html( data );
        });
    });
    $(".nganhnghe").change(function(){
        var e = $(this);
        var p = e.parent().parent().parent().parent();

        //p.find(".home_content_one").html( "<?php echo DOMAIN;?>home/ajax/" + p.attr('parent_id') + "/" + e.val() );
        var c = p.find(".home_content_one");
        var choose = 1;
        var tmp = p.find(".home_content_two");
        if(tmp.length) {c=tmp;choose=2;}

        $.post( "<?php echo DOMAIN;?>home/ajax/"+choose+"/" + p.attr('parent_id') + "/" + e.val(), function( data ) {
          c.html( data );
        });
    });
});
</script>